import _ from 'lodash';

function fetchData(page) {
  // 发送请求获取数据
}

const lazyload = _.throttle(() => {
  const list = document.querySelector('.list');
  const { scrollTop, scrollHeight, clientHeight } = list;

  if (scrollTop + clientHeight >= scrollHeight - 10) {
    // 计算当前页数并发送请求获取数据
    const nextPage = Math.ceil(list.children.length / 10) + 1;
    fetchData(nextPage);
  }
}, 300);

const listElement = document.querySelector('.list');
listElement.addEventListener('scroll', lazyload);